package com.tjtt.tdm.system.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.tjtt.tdm.base.PageResult;
import com.tjtt.tdm.exception.DaoException;
import com.tjtt.tdm.exception.ServiceException;
import com.tjtt.tdm.system.bean.Role;
import com.tjtt.tdm.system.bean.Rolemenu;
import com.tjtt.tdm.system.bean.UserRole;


/**
 * 角色模块,service层
 * @author leung
 *
 */
public interface RoleService {
	/**
	 * 根据条件查询角色信息
	 * @param paramMap
	 * @param totalCount
	 * @param start
	 * @param limit
	 * @param sort
	 * @param dir
	 * @return
	 * @throws ServiceException
	 */
	public List<Role> findRoles(HashMap<String, Object> paramMap,long totalCount, long start,
			long limit, String sort, String dir) throws ServiceException;
	/**
	 * 根据roleId获取用户对象
	 * @param roleId
	 * @return
	 * @throws ServiceException
	 */
	public Role get(Long roleId)throws ServiceException;
	/**
	 * 根据参数获取角色总数
	 * @param paramMap
	 * @return
	 * @throws ServiceException
	 */
	public Long getTotalCount(HashMap<String, Object> paramMap) throws ServiceException;
	
	/**
	 * 角色保存
	 * @param role
	 * @throws ServiceException
	 */
	public void saveRole(Role role) throws ServiceException;
	/**
	 * 角色修改
	 * @param role
	 * @throws ServiceException
	 */
	public void updateRole(Role role)throws ServiceException;
	/**
	 * 角色删除
	 * @param roleid
	 * @throws ServiceException
	 */
	public void delRole(Long roleid) throws ServiceException;
	/**
	 * 根据roleId和menuId查询角色菜单表中是否有记录
	 * @param roleId
	 * @param menuId
	 * @return
	 * @throws ServiceException
	 */
	public boolean findRoleMenuByMenuIdAndRoleId(Long roleId,Long menuId) throws ServiceException;
	
	/**
	 * 修改角色菜单对应关系
	 * @param roleId
	 * @param menuIds
	 * @throws ServiceException
	 */
	public void updateRoleMenuByRoleId(Long roleId,List<Long> menuIds) throws ServiceException;
	
	/**
	 * 获取所有角色信息
	 * @return
	 * @throws ServiceException
	 */
	public List<Role> getRolesAll() throws ServiceException;
	/**
	 * 根据roleId和menuParentId组合查询角色菜单表与菜单表,找出角色表中属于parentId的总数
	 * @param roleId
	 * @param menuParentId
	 * @return
	 * @throws ServiceException
	 */
	public int findRoleMenuByMenuIdsAndRoleId(Long roleId,Long menuParentId) throws ServiceException;
	/**
	 * 根据roleId获取该角色所拥有的菜单功能主键
	 * @param roleId
	 * @return
	 */
	public List<Rolemenu> getRolemenuByRoleId(Long roleId) throws ServiceException;
	/**查询所有角色的方法*/
	public List<Role> findAllRole()throws ServiceException;
	
    /**
     * 通过id查询角色信息
     * @author 宿馨月
     * @date 2012-10-15 下午14:12:15
     */
    public Role findRoleById(long roleid);	
    /**
     * 系统角色树形展示
     * @param filterMap
     * @return
     * @throws ServiceException List<Role>
     * @author 詹晓梅
     * @date 2013-1-23 下午02:28:49
     */
    public List<Role> findRoleTree(Map filterMap)throws ServiceException;
    /**
     * 查询角色名称是否存在
     * @param rolename
     * @param filterMap
     * @return
     * @throws ServiceException PageResult
     * @author 詹晓梅
     * @date 2013-1-24 下午03:54:29
     */
   // public PageResult findRoleByNames(String rolename,Map<String, String> filterMap)throws ServiceException;
    
    public Role findRoleByName(String rName);
    /**
     * 查询角色下用户
     * @param ids
     * @param filterMap
     * @return PageResult
     * @author 詹晓梅
     * @date 2013-1-30 下午05:31:54
     */
    public PageResult searchUserByRole(Long roleid, Map<String, String> filterMap);
    
    public UserRole savaUserToRole(UserRole userRole);
    
    public PageResult queryUserList(Long roleid, Map<String, String> filterMap);
    
    public List queryListBySql(String sql);
    //根据角色查询用户
	public PageResult queryUserByRole(String roleid, Map<String, String> filterMap);
	
	public void exeSql(String sql);
}
